package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.Page;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.service.PermissionService;
import org.springframework.security.acls.model.PermissionGrantingStrategy;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhouwei
 * @date 2020-01-16 18:22
 */
@RestController
@RequestMapping("/permission")
public class PermissionController {
    @Reference
    private PermissionService permissionService;

    /**
     * 分页查询
     * @param queryPageBean
     * @return
     */
    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        try {
            String queryString = queryPageBean.getQueryString();
            if(queryString!=null&&queryString.length()!=0) {
                String s = queryString.replaceAll(" ", "");
                queryPageBean.setQueryString(s);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        PageResult pageResult=permissionService.findPage(queryPageBean);
        return pageResult;
    }
}
